<template>
  <el-tree
    ref="tree"
    :node-key="nodeKey"
    :data="data"
    @node-click="nodeClick"
    :default-expand-all="defaultExpandAll"
    :highlight-current="highlightCurrent"
    :expand-on-click-node="expandOnClickNode"
  >
    <slot></slot>
  </el-tree>
</template>
<script>
export default {
  name: 'CTree',
  components: {},
  props: {
    data: {
      type: Array,
      default() {
        return []
      }
    },
    nodeKey: { type: String, default: '' },
    defaultExpandAll: { type: Boolean, default: true },
    highlightCurrent: { type: Boolean, default: true },
    expandOnClickNode: { type: Boolean, default: true }
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
  methods: {
    nodeClick(...args) {
      this.$emit('click', ...args)
    },
    setNodeKey(node) {
      this.$refs.tree.setCurrentKey(node[this.nodeKey])
    }
  }
}
</script>
<style lang="scss" scoped></style>
